package com.xjtu.platform.mainAction;

import com.xjtu.platform.mainAction.dto.CreateDto;
import com.xjtu.platform.mainAction.dto.UpdateDto;
import com.xjtu.platform.mainAction.entity.Article;
import org.apache.ibatis.annotations.*;

import java.sql.Timestamp;
import java.util.List;

@Mapper
public interface MainDao {

    @Insert("insert into article (article_content,article_title,start_time) values(#{dto.content},#{dto.title},#{time})")
    void createArticle(@Param("dto") CreateDto createDto, @Param("time") Timestamp nowTime);

    @Select("select article_content as content, article_title as title , start_time, article_id , update_time from article order by start_time desc")
    List<Article> getAllArticle();

    @Update("update article set article_title=#{dto.title},article_content = #{dto.content},update_time = #{time} where article_id = #{dto.article_id}")
    void updateArticle(@Param("dto")UpdateDto updateDto, @Param("time")Timestamp nowTime);
}
